<template>
	<view class="personal-content">
		<!-- 用户信息 -->
		<view class="user-info">
			<view class="user-bg">
				<image src="/static/forum/circleBg.png" mode="scaleToFill"></image>
			</view>
			<view class="user-message">
				<view class="user-avatar">
					<image :src="userInfo.avatar"></image>
				</view>
				<view class="user-title">
					<view class="user-name">{{ userInfo.nickname }}</view>
					<view class="user-like">{{ userPhone }}</view>
				</view>
			</view>
		</view>
		<!-- 导航栏 -->
		<view class="nav-content">
			<view class="func-title">功能模块</view>
			<view class="nav-list">
				<view class="nav-data" v-for="(item, index) in nav_data" :key="item.id" @click="toDetail(index)">
					<view class="mount">{{ item.mount }}</view>
					<view class="title">{{ item.title }}</view>
				</view>
				<view class="line"></view>
			</view>
		</view>
		<!-- 其他功能 -->
		<!-- 	<view class="other-serve">
			<view class="func-title">其他功能</view>
			<view class="btn-list">
				<view class="func-btn" v-for="(item, index) in btnList" :key="index">
					<view class="btn-pic"></view>
					<view class="btn-name">功能按钮{{ item }}</view>
				</view>
				<view class="empty-btn" v-for="(item, index) in emptyBtn" :key="index"></view>
			</view>
		</view> -->

		<!-- 技术支持 -->
		<!-- <image class="tec-apport" src="/static/tec.png" mode="aspectFit"></image> -->

		<!-- 缺省 -->
		<view class="default-height" style="width: 100%;height: 92rpx;"></view>
		<ikz-tabbar :show-data="tabbar_Data"></ikz-tabbar>
	</view>
</template>

<script>
	var app = getApp()
	import ikzTabbar from '@/pages/Component/Public/tab-bar/tab-bar.vue'
	import ikz from '@/pages/Common/tools.js'
	export default {
		components: {
			ikzTabbar,
		},
		data() {
			return {
				userInfo: {}, //用户信息
				userPhone: undefined,
				nav_data: [{
						id: 1,
						mount: 0,
						title: '我的帖子',
						url: '/pages/Component/forum/Program/personal/nav-menu/myposts',
					},
					{
						id: 2,
						mount: 0,
						title: '我的频道',
						url: '/pages/Component/forum/Program/personal/nav-menu/mycircle',
					},
					{
						id: 3,
						mount: 0,
						title: '我的收藏',
						url: '/pages/Component/forum/Program/personal/nav-menu/mylike?status=1',
					},
					{
						id: 4,
						mount: 0,
						title: '我的点赞',
						url: '/pages/Component/forum/Program/personal/nav-menu/mylike?status=2',
					},
				],
				tabbar_Data: {
					type: 3,
					list: [{
							title: '首页',
							url: '/pages/Component/forum/Program/index/index',
							iconPath: '/static/forum/tabbar/index.png',
							selectedIconPath: '/static/forum/tabbar/index-check.png',
							status: 1,
						},
						{
							title: '频道',
							url: '/pages/Component/forum/Program/circle/circle',
							iconPath: '/static/forum/tabbar/circle.png',
							selectedIconPath: '/static/forum/tabbar/circle-check.png',
							status: 1,
						},
						{
							title: '发布',
							url: '/pages/Component/forum/Program/release/release',
							iconPath: '/static/forum/tabbar/release.png',
							selectedIconPath: '/static/forum/tabbar/release-check.png',
							status: 1,
						},
						{
							title: '我的',
							url: '/pages/Component/forum/Program/personal/personal',
							iconPath: '/static/forum/tabbar/mine.png',
							selectedIconPath: '/static/forum/tabbar/mine-check.png',
							status: 1,
						},
					],
				},
				btnList: ['1', '2', '3', '4', '5', '6'],
			}
		},
		onLoad() {
			this.userInfo = uni.getStorageSync('user_info')
			this.userPhone = app.globalData.mobile || ''
			this.getQuantity()
		},
		onShow() {
			this.getQuantity()
			uni.hideHomeButton()
		},
		computed: {
			emptyBtn() {
				if (this.btnList.length % 4 == 0) {
					return 0
				}
				return 4 - (this.btnList.length % 4)
			},
		},
		methods: {
			// 跳转页面
			toDetail(index) {
				uni.navigateTo({
					url: this.nav_data[index].url,
				})
			},
			// 获取我关注的数量
			getQuantity() {
				let path = '/xyb/posts/posts/quantity'
				let data = {
					token: uni.getStorageSync('local_user_session'),
				}
				ikz.requestPost(path, data, res => {
					// console.log('获取我关注的数量', res.data.data)
					if (res.statusCode == 200) {
						// this.infoData = res.data.data
						this.nav_data[0].mount = res.data.data.posts
						this.nav_data[1].mount = res.data.data.circle
						this.nav_data[2].mount = res.data.data.collection
						this.nav_data[3].mount = res.data.data.give
					}
				})
			},
		},
	}
</script>

<style lang="scss">
	page {
		background-color: #f8f8f8;
	}

	.personal-content {
		overflow: hidden;
		padding: 0 0 106rpx;
		background-color: #f8f8f8;

		.func-title {
			font-weight: 600;
			font-size: 32rpx;
			line-height: 44rpx;
			color: #333333;
		}

		.user-info {
			position: relative;

			.user-bg {
				position: absolute;
				width: 100%;
				height: 360rpx;

				image {
					width: 100%;
					height: 100%;
				}
			}

			.user-message {
				position: relative;
				z-index: 2;
				display: flex;
				align-items: center;
				width: 100%;
				// height: 256rpx;
				padding: 64rpx 38rpx;

				.user-avatar {
					width: 128rpx;
					height: 128rpx;

					image {
						width: 100%;
						height: 100%;
						border-radius: 50%;
					}
				}

				.user-title {
					flex: 1;
					margin-left: 40rpx;
					// height: 100rpx;
					color: #ffffff;

					.user-name {
						font-size: 48rpx;
						line-height: 68rpx;
						margin-bottom: 8rpx;
					}

					.user-like {
						font-size: 28rpx;
						line-height: 40rpx;
					}
				}
			}
		}

		.nav-content {
			box-sizing: border-box;
			position: relative;
			z-index: 2;
			width: 700rpx;
			margin: 0 auto 16rpx;
			padding: 24rpx 32rpx 32rpx;
			background: #ffffff;
			border-radius: 5px;

			.nav-list {
				display: flex;
				position: relative;

				.line {
					position: absolute;
					top: 52%;
					width: 90%;
					height: 1rpx;
					background-color: rgba(0, 0, 0, 0.1);
				}

				.nav-data {
					box-sizing: border-box;
					flex: 49%;
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: space-between;
					margin: 18rpx auto 0;
					padding: 30rpx 0;
					font-size: 30rpx;

					&:nth-child(-n + 2) {
						margin-bottom: 34rpx;
					}

					&:nth-child(n + 3) {
						margin-top: 34rpx;
					}

					&:nth-child(2n-1) {
						padding-right: 30rpx;
						border-right: 0.5px solid rgba(0, 0, 0, 0.1);
					}

					&:nth-child(2n) {
						padding-left: 30rpx;
					}

					.mount {
						font-size: 40rpx;
						line-height: 56rpx;
					}

					.title {
						font-size: 28rpx;
						line-height: 40rpx;
						color: #666666;
					}
				}
			}
		}

		.other-serve {
			box-sizing: border-box;
			width: 700rpx;
			margin: 0 auto;
			padding: 24rpx 32rpx 32rpx;
			background: #ffffff;
			border-radius: 5px;

			.btn-list {
				display: flex;
				flex-wrap: wrap;

				.func-btn {
					flex: 25%;
					display: flex;
					flex-direction: column;
					align-items: center;
					margin-top: 48rpx;

					.btn-pic {
						overflow: hidden;
						width: 80rpx;
						height: 80rpx;
						margin-bottom: 24rpx;
						background-color: #ccc;
						border-radius: 50%;
					}

					.btn-name {
						font-size: 24rpx;
						line-height: 34rpx;
						color: #000000;
					}
				}

				.empty-btn {
					flex: 25%;
				}
			}
		}

		.tec-apport {
			height: 50rpx;
			position: fixed;
			top: 85%;
			left: 50%;
			transform: translate(-50%, -50%);
		}
	}
</style>